#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QInputDialog>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //创建三个按钮，分别对应着输入整数、浮点数、条目选择输入框
    QPushButton *button1=new QPushButton("点击输入整数",this);
    button1->setGeometry(100,100,200,100);
    QPushButton *button2=new QPushButton("点击输入浮点数",this);
    button2->setGeometry(100,250,200,100);
    QPushButton *button3=new QPushButton("点击输入/选择条目",this);
    button3->setGeometry(100,400,200,100);

    connect(button1,&QPushButton::clicked,this,&MainWindow::handler1);
    connect(button2,&QPushButton::clicked,this,&MainWindow::handler2);
    connect(button3,&QPushButton::clicked,this,&MainWindow::handler3);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handler1()
{
    int value=QInputDialog::getInt(this,"整数输入对话框","请输入整数:");
    qDebug()<<value;
}

void MainWindow::handler2()
{
    double value=QInputDialog::getDouble(this,"浮点数输入对话框","请输入浮点数:");
    qDebug()<<value;
}

void MainWindow::handler3()
{
    QStringList items;
    items.push_back("111");
    items.push_back("222");
    items.push_back("333");
    QString value=QInputDialog::getItem(this,"条目输入对话框","请输入或选择条目:",items);
    qDebug()<<value;
}

